<?php
class ConfigsController extends Controller
{
	public $layout = 'main';

	public function actionIndex()
	{
		//update
		if(Yii::app()->request->isPostRequest)
		{
			$arrParams = Yii::app()->request->getParam('configs', null);
			foreach($arrParams as $code=>$value){
				Settings::getInstance()->update($code, $value);
			}
			Yii::app()->admin->setFlash('ok', Yii::t('AdmincpModule.admincp', 'Update successfully'));
		}
		//load data
		$arrSettings  = Settings::getInstance()->getList();
		//render view
		$this->render('index', array(
			'arrSettings' => $arrSettings
		));
	}
}